/*
 * Copyright (c) www.bugull.com
 */
package com.bugull.farm.device.server.processor;


import com.bugull.farm.core.frame.structure.Frame;
import com.bugull.farm.core.handler.Processor;
import com.bugull.farm.core.store.Device;
import com.bugull.farm.core.utils.ByteUtil;
import com.bugull.mongo.BuguDao;
import com.bugull.mongo.BuguQuery;
import com.bugull.mongo.cache.DaoCache;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;

/**
 *
 * @author Frank Wen(xbwen@hotmail.com)
 */
public class DeviceInfoProcessor implements Processor {
	
    @Override
    public void process(ChannelHandlerContext ctx, Frame frame) throws Exception {
        //更新设备的基础信息
        String mac = frame.getHexStr("mac");
        String sVer = frame.getASCIIStr("sver");
        BuguDao<Device> dao = DaoCache.getInstance().get(Device.class);
        BuguQuery<Device> query = dao.query().is("macAddress", mac);
        dao.update().set("softVersion", sVer).execute(query);
    }
    
}
